package io.renren.modules.health.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.health.dao.SportPlanDetailDao;
import io.renren.modules.health.dto.SportPlanDetailDTO;
import io.renren.modules.health.entity.SportPlanDetailEntity;
import io.renren.modules.health.service.SportPlanDetailService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 
 *
 * @author Mark 
 * @since 1.0.0 2024-03-29
 */
@Service
public class SportPlanDetailServiceImpl extends CrudServiceImpl<SportPlanDetailDao, SportPlanDetailEntity, SportPlanDetailDTO> implements SportPlanDetailService {

    @Override
    public QueryWrapper<SportPlanDetailEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        Long sportPlanId = (Long)params.get("sportPlanId");
        List<Long> sportPlanIds = (List<Long>) params.get("sportPlanIds");

        QueryWrapper<SportPlanDetailEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.eq(!Objects.isNull(sportPlanId), "sport_plan_id", sportPlanId);
        wrapper.in(!Objects.isNull(sportPlanIds) && !sportPlanIds.isEmpty(), "sport_plan_id", sportPlanIds);

        return wrapper;
    }


}